package org.proddevplm.dao.core;

import org.hibernate.Query;
import org.hibernate.Session;
import org.proddevplm.dao.api.IToolsMgmt;
import org.proddevplm.dao.data.changeReport.ChangeReport;
import org.proddevplm.dao.data.competitors.Competitors;
import org.proddevplm.dao.data.competitors.CompetitorsProduct;
import org.proddevplm.dao.data.conceptSelection.PughAnalysis;
import org.proddevplm.dao.data.conceptSelection.PughCriteria;
import org.proddevplm.dao.data.correlations.QFD;
import org.proddevplm.dao.data.designForX.DesignForX;
import org.proddevplm.dao.data.designForX.DfXGImportances;
import org.proddevplm.dao.data.designForX.DfXGuidelines;
import org.proddevplm.dao.data.designForX.DfXImportances;
import org.proddevplm.dao.data.designForX.DfXRelMatrix;
import org.proddevplm.dao.data.designInputs.CTQs;
import org.proddevplm.dao.data.designInputs.DesignElements;
import org.proddevplm.dao.data.designInputs.ProductFunctions;
import org.proddevplm.dao.data.prioritize.AHPAnalysis;
import org.proddevplm.dao.data.requirements.Requirements;
import org.proddevplm.dao.data.requirements.VOCTable;
import org.proddevplm.dao.data.stakeholders.Stakeholder;
import org.proddevplm.dao.data.swot.SwotAnalysis;
import org.proddevplm.dao.util.HibernateUtil;

public class ToolsMgmt implements IToolsMgmt{

	@Override
	public boolean addCompetitor(Competitors competitor) {
		
		HibernateUtil.currentSession().persist(competitor);
		
		return false;
	}

	@Override
	public boolean addCompProduct(CompetitorsProduct compProduct) {

		HibernateUtil.currentSession().persist(compProduct);
		
		return false;
	}

	@Override
	public boolean addSwotAnalysis(SwotAnalysis swotAnalysis) {
		
		HibernateUtil.currentSession().persist(swotAnalysis);
		
		return false;
	}

	@Override
	public boolean addStakeholder(Stakeholder stakeholder) {

		HibernateUtil.currentSession().persist(stakeholder);
		
		return false;
	}

	@Override
	public boolean deleteStakeholderByName(String shName, int productId) {

		Session session = HibernateUtil.currentSession();
		Query q = session.createQuery("delete from Stakeholder sh where sh.shName=:shName and sh.productId=:productId");
		q.setString("shName", shName);
		q.setInteger("productId", productId);
		q.executeUpdate();
		return false;
	}

	@Override
	public boolean addRequirement(Requirements requirement) {

		HibernateUtil.currentSession().persist(requirement);
		
		return false;
	}

	@Override
	public boolean deleteReqByNameandProdId(String requirement, int productId) {
		
		Session session = HibernateUtil.currentSession();
		Query q = session.createQuery("delete from Requirements r where r.requirement=:requirement and r.productId=:productId");
		q.setString("requirement", requirement);
		q.setInteger("productId", productId);
		q.executeUpdate();
		return false;
	}

	@Override
	public boolean updateRequirement(Requirements requirement) {
		
		HibernateUtil.currentSession().merge(requirement);
		
		return false;
	}

	@Override
	public boolean addAhpAnalysis(AHPAnalysis analysis) {

		HibernateUtil.currentSession().persist(analysis);
		
		return false;
	}

	@Override
	public boolean addVOCT(VOCTable voct) {

		HibernateUtil.currentSession().persist(voct);
		
		return false;
	}

	@Override
	public boolean addProductFunction(ProductFunctions pf) {
		
		HibernateUtil.currentSession().persist(pf);
		
		return false;
	}

	@Override
	public boolean addCTQ(CTQs ctq) {
		
		HibernateUtil.currentSession().persist(ctq);
		
		return false;
	}

	@Override
	public boolean addDesignElement(DesignElements de) {

		HibernateUtil.currentSession().persist(de);
		
		return false;
	}

	@Override
	public boolean updateSwotAnalysis(SwotAnalysis currentSwot) {
		
		HibernateUtil.currentSession().merge(currentSwot);
		
		return false;
	}

	@Override
	public boolean deleteProductFunction(String functionName, int productId) {
		Session session = HibernateUtil.currentSession();
		Query q = session.createQuery("delete from ProductFunctions pf where pf.function=:functionName and pf.productId=:productId");
		q.setString("functionName", functionName);
		q.setInteger("productId", productId);
		q.executeUpdate();
		return false;
	}

	@Override
	public boolean deleteCTQ(String ctqName, int productId) {
		Session session = HibernateUtil.currentSession();
		Query q = session.createQuery("delete from CTQs c where c.ctq=:ctqName and c.productId=:productId");
		q.setString("ctqName", ctqName);
		q.setInteger("productId", productId);
		q.executeUpdate();
		return false;
	}

	@Override
	public boolean deleteDE(String deName, int productId) {
		Session session = HibernateUtil.currentSession();
		Query q = session.createQuery("delete from DesignElements de where de.designElement=:deName and de.productId=:productId");
		q.setString("deName", deName);
		q.setInteger("productId", productId);
		q.executeUpdate();
		return false;
	}

	@Override
	public boolean addChangeReport(ChangeReport cr) {
		
		HibernateUtil.currentSession().persist(cr);
		
		return false;
	}

	@Override
	public boolean addPughAnalysis(PughAnalysis pugh) {

		HibernateUtil.currentSession().merge(pugh);
		
		return false;
	}

	@Override
	public boolean updateStakeholder(Stakeholder stakeholder) {
		
		HibernateUtil.currentSession().update(stakeholder);
		
		return false;
	}

	@Override
	public boolean updateCTQ(CTQs ctq) {
		
		HibernateUtil.currentSession().update(ctq);
		
		return false;
	}

	@Override
	public boolean addQFD(QFD qfd) {

		HibernateUtil.currentSession().persist(qfd);
		
		return false;
	}

	@Override
	public boolean updateQFD(QFD qfd) {
		
		HibernateUtil.currentSession().update(qfd);
		
		return false;
	}

	@Override
	public boolean updateProductFunction(ProductFunctions pf) {

		HibernateUtil.currentSession().update(pf);
		
		return false;
	}

	@Override
	public boolean updateDesignElement(DesignElements de) {
		
		HibernateUtil.currentSession().update(de);
		
		return false;
	}

	@Override
	public boolean addDFX(DesignForX dfx) {
		
		HibernateUtil.currentSession().persist(dfx);
		
		return false;
	}

	@Override
	public boolean updateDFX(DesignForX dfx) {
		
		HibernateUtil.currentSession().update(dfx);
		
		return false;
	}

	@Override
	public boolean addDfXGuideline(DfXGuidelines guideline) {

		HibernateUtil.currentSession().persist(guideline);
		
		return false;
	}

	@Override
	public boolean updateDfXGuideline(DfXGuidelines guideline) {
		
		HibernateUtil.currentSession().update(guideline);
		
		return false;
	}

	@Override
	public boolean addDfXRelMatrix(DfXRelMatrix dfxRM) {
		
		HibernateUtil.currentSession().persist(dfxRM);
		
		return false;
	}

	@Override
	public boolean deleteDfXRelMatrix(int dfxRMId) {
		Session session = HibernateUtil.currentSession();
		Query q = session.createQuery("delete from DfXRelMatrix d where d.id=:dfxRMId");
		q.setInteger("dfxRMId", dfxRMId);
		q.executeUpdate();
		return false;
	}

	@Override
	public boolean addDfXImportance(DfXImportances dfxI) {
		
		HibernateUtil.currentSession().persist(dfxI);
		
		return false;
	}

	@Override
	public boolean addDfXGImportance(DfXGImportances dfxGI) {

		HibernateUtil.currentSession().persist(dfxGI);
		
		return false;
	}	
}
